<template>
    <u-tabbar :value="value" :placeholder="true" :border="false" @change="toLink" :fixed="true"
        :safeAreaInsetBottom="true">
        <u-tabbar-item :text="item.name" :icon="item.icon" v-for="item in list" :key="item"></u-tabbar-item>
    </u-tabbar>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
let list = [
    {
        name: '首页',
        icon: 'home',
        link: 'pages/index/index'
    },
    {
        name: '业务员',
        icon: 'server-man',
        link: 'pages/credit-loans/salesman'
    },    {
        name: '咨询',
        icon: 'order',
        link: 'pages/application-record/application-record?is_ywy=0'
    },
	
    {
        name: '我的',
        icon: 'account',
        link: 'pages/mine/mine'
    },
]
const pages = getCurrentPages();
const page = pages[pages.length - 1];
let value = computed(() => {
    return list.findIndex((item) => item.link == page.route)
})
function toLink(index: number) {
    if (list[index].icon == 'order' || list[index].icon == 'server-man') {
        uni.navigateTo({
            url: '/' + list[index].link
        })
    } else {
        uni.redirectTo({
            url: '/' + list[index].link
        })
    }
}
</script>	